package com.itheima.dao;

import com.itheima.domain.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StudentDao {
    /**
     * 添加学生
     * @param student
     * @return
     */
    @Insert("INSERT INTO student VALUES (null,#{name},#{age},#{birthday})")
    boolean save(Student student);

    /**
     * 修改学生
     * @param student
     * @return
     */
    @Update("update student set name=#{name},age=#{age},birthday=#{birthday} where id=#{id}")
    boolean update(Student student);

    /**
     * 删除学生
     * @param id
     * @return
     */
    @Delete("delete from student where id=#{id}")
    boolean delete(Integer id);

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @Select("Select*from student where id = #{id}")
    Student findById(Integer id);

    /**
     * 查询全部
     * @return
     */
    @Select("SELECT * FROM student")
    List<Student> findAll();

}
